﻿@using XRepair.Conventions.Enum
@using xCache = MvcXRepairAdmin.CacheData

@model XRepair.Models.Model

@{
    Layout = null;

    List<XRepair.Models.Brand> activeBrands = MvcXRepairAdmin.CacheData.Cache.GetAllActiveBrands();

    var brandTypes = activeBrands.ConvertAll<SelectListItem>(x => new SelectListItem { Value = x.ID.Value.ToString(), Text = x.BrandName });

    brandTypes.Insert(0, new SelectListItem { Value = string.Empty, Text = "Select brand", Selected = true });    
}

@using (Html.BeginForm("AddNew", "Model", FormMethod.Post))
{
    <table>
        <tbody>
            <tr>
                <td>Brand</td>
                <td>
                    @Html.DropDownListFor(x => x.BrandID, brandTypes)</td>
            </tr>

            <tr>
                <td>Model Name</td>
                <td>
                    @Html.TextBoxFor(x => x.ModelName) </td>
            </tr>

            <tr>
                <td>Version</td>
                <td>
                    @Html.TextBoxFor(x => x.Version) </td>
            </tr>

            <tr>
                <td>Manufacturer</td>
                <td>
                    @Html.TextBoxFor(x => x.Manufacturer) </td>
            </tr>
        </tbody>
    </table>
    
    <input type="submit" value="Add" /><input type="button" value="Cancel" id="btnCancelAdd" />
}
